package com.hunttown.mes.rpc.domain.enums.iot.alarm;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 报警类型：通讯中断/越上限/越下限/状态变化
 * created by wangjunfu on 2019/08/19
 */
public enum MantunAlarmTypeEnum {
    ALARM0(0, "未知"),
    ALARM1(1, "短路报警"),
    ALARM2(2, "漏电报警"),
    ALARM3(3, "过载报警"),
    ALARM4(4, "过流报警"),
    ALARM5(5, "过压报警"),
    ALARM6(6, "欠压报警"),
    ALARM7(7, "温度报警"),
    ALARM8(8, "浪涌报警"),
    ALARM9(9, "漏电保护功能正常"),
    ALARM10(10, "漏电保护自检未完成"),
    ALARM11(11, "打火报警"),
    ALARM12(12, "漏电预警"),
    ALARM13(13, "电流预警"),
    ALARM14(14, "过压预警"),
    ALARM15(15, "欠压预警"),
    ALARM16(16, "通讯报警"),
    ALARM17(17, "输入缺相"),
    ALARM18(18, "三相不平衡"),
    ALARM19(19, "相序报警"),
    ALARM20(20, "A相短路报警"),
    ALARM21(21, "A相过载报警"),
    ALARM22(22, "A相过流报警"),
    ALARM23(23, "A相过压报警"),
    ALARM24(24, "A相欠压报警"),
    ALARM25(25, "A相温度报警"),
    ALARM26(26, "A相打火报警"),
    ALARM27(27, "A相电流预警"),
    ALARM28(28, "A相过压预警"),
    ALARM29(29, "A相欠压预警"),
    ALARM30(30, "A相输入缺相"),
    ALARM31(31, "B相短路报警"),
    ALARM32(32, "B相过载报警"),
    ALARM33(33, "B相过流报警"),
    ALARM34(34, "B相过压报警"),
    ALARM35(35, "B相欠压报警"),
    ALARM36(36, "B相温度报警"),
    ALARM37(37, "B相打火报警"),
    ALARM38(38, "B相电流预警"),
    ALARM39(39, "B相过压预警"),
    ALARM40(40, "B相欠压预警"),
    ALARM41(41, "B相输入缺相"),
    ALARM42(42, "C相短路报警"),
    ALARM43(43, "C相过载报警"),
    ALARM44(44, "C相过流报警"),
    ALARM45(45, "C相过压报警"),
    ALARM46(46, "C相欠压报警"),
    ALARM47(47, "C相温度报警"),
    ALARM48(48, "C相打火报警"),
    ALARM49(49, "C相电流预警"),
    ALARM50(50, "C相过压预警"),
    ALARM51(51, "C相欠压预警"),
    ALARM52(52, "C相输入缺相"),
    ALARM53(53, "掉电报警"),
    ALARM54(54, "开箱报警"),
    ALARM1001(1001, "组态报警"),
    ALARM1002(1002, "离线报警"),
    ALARM1003(1003, "分闸警示"),
    ALARM1004(1004, "合闸警示"),
    ALARM1005(1005, "异常分闸"),
    ALARM2002(2002, "烟气报警"),
    ALARM2003(2003, "压强报警"),
    ALARM2004(2004, "液位报警"),
    ALARM9000(9000, "设备故障");

    private final int key;
    private final String value;

    MantunAlarmTypeEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    // 根据key获取枚举
    public static String getEnumByKey(int key) {
        String value = "";

        for (MantunAlarmTypeEnum temp : MantunAlarmTypeEnum.values()) {
            if (temp.getKey() == key) {
                value = temp.getValue();
            }
        }

        return value;
    }

    // 将枚举组成Map
    public static Map<Integer, String> getEnumList() {
        Map<Integer, String> map = new HashMap<>();

        for (MantunAlarmTypeEnum temp : MantunAlarmTypeEnum.values()) {
            map.put(temp.getKey(), temp.getValue());
        }

        return map;
    }

    // 将枚举组成Map（因为枚举是公用的，所以不同项目选择的不一样）
    public static Map<Integer, String> getEnumList(List<Integer> keys) {
        Map<Integer, String> map = new HashMap<>();

        for (MantunAlarmTypeEnum temp : MantunAlarmTypeEnum.values()) {
            if (keys.contains(temp.getKey())) {
                map.put(temp.getKey(), temp.getValue());
            }
        }

        return map;
    }

    // key以字符串的形式返回
    public static Map<String, String> getEnumListString() {
        Map<String, String> map = new HashMap<>();

        for (MantunAlarmTypeEnum temp : MantunAlarmTypeEnum.values()) {
            map.put(temp.getKey() + "", temp.getValue());
        }

        return map;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
